home *** CD-ROM | disk | FTP | other *** search
- ;«RM82»«TS7,16,24,32,40,48»
- ; updated 11/16/90
-
- ;============================================================================
- ; Copyright (C) Copr. 1990 by Sidney J. Kelly
- ; All Rights Reserved.
- ; Sidney J. Kelly
- ; 150 Woodhaven Drive
- ; Pittsburgh, PA 15228
- ; home phone 412-561-0950 (7pm to 9:30pm EST)
- ;============================================================================
-
- ;=======================================================================
- ;DECLARE SUB REVERSESTRING (A$)
- ;will reverse A$
- ;
- ;DECLARE SUB LEFTROTATE (A$)
- ;will rotate a string one character to the left
- ;
- ;DECLARE SUB RIGHTROTATE (A$)
- ;will rotate a string one character to the right
- ;
- ;=======================================================================
-
- DOSSEG
- .model medium
- .code
- public REVERSESTRING, LEFTROTATE, RIGHTROTATE
-
- ; Please do not remove
- Copyright DB 13,10,'Copyright Copr. (C) 1990 Sidney J. Kelly',13,10
- Copyright1 DB 'All Rights Reserved',13,10,26
-
- EVEN
- REVERSESTRING Proc Far
- Push BP
- Mov BP,SP
- Push DI
- Mov BX,[BP+6]
- Mov CX,[BX]
- Mov DI,[BX+2]
- Mov BX,CX
- Shr CX,1 ;divide by 2
- Jcxz finis1 ;if length less than 2, then quit
- Add BX,DI ;put length + address in BX
- Dec BX ;reduce by one
- looper1:
- Mov AH,[DI]
- Mov AL,[BX]
- Mov [BX],AH
- Mov [DI],AL
- Inc DI
- Dec BX
- Loop looper1
- finis1:
- Pop DI
- Pop BP
- Ret 2
- REVERSESTRING ENDP
-
- EVEN
- LEFTROTATE Proc Far
- Push BP
- Mov BP,SP
- Push SI
- Push DI
- Mov BX,[BP+6] ; get string
- Mov CX,[BX]
- Cmp CX,2 ; quit if length < 2
- JB finis2
- Mov SI,[BX+2] ; put offset in SI
- Mov AX,DS
- Mov ES,AX
-
- ASSUME ES:@data
-
- Mov DL,[SI]
- Mov DI,SI
- Inc SI
- Dec CX
- Cld
- Repz Movsb
- Mov [DI],DL
- finis2:
- Jmp short finis3
- LEFTROTATE endp
-
- EVEN
- RIGHTROTATE Proc Far
- Push BP
- Mov BP,SP
- Push SI
- Push DI
- Mov BX,[BP+6]
- Mov CX,[BX]
- Cmp CX,2
- JB finis3 ;string len < 2
- Mov SI,[BX+2]
- Mov AX,DS
- Mov ES,AX
-
- ASSUME ES:@data
-
- Add SI,CX
- Dec SI
- Mov DL,[SI]
- Mov DI,SI
- Dec SI
- Dec CX
- Std
- Repz Movsb
- Mov [DI],DL
- Cld
- finis3::
- Pop DI
- Pop SI
- Pop BP
- Ret 2
- RIGHTROTATE endp
- end
-